import { DEFAULT_LOGIN_PATH } from "../../../packages/constants/src";
import LoginView from "@/layouts/authentication/LoginView.vue";
import type { RouteRecordRaw } from "vue-router";

/** 全局404页面 */
// RouteRecordRaw 是 Vue Router 4 中新增的一个类型定义。它是用于定义路由记录的。
// 使用 RouteRecordRaw 来定义路由配置，可以使得路由配置更加清晰和类型安全。（方便typescript进行类型检查！）
const fallbackNotFoundRoute: RouteRecordRaw = {
  component: () => import("@/views/fallback/NotFound.vue"),
  meta: {
    title: "404",
  },
  name: "FallbackNotFound",
  path: "/:path(.*)*",
};

/**
 * @zh_CN 动态路由
 * 配置静态路由，这些路由是必须存在的 */
const coreRoutes: RouteRecordRaw[] = [
  {
    name: 'InitStaticRootRoute',
    path: '/',
    redirect: {name: 'Authentication'}
  },
  {
    name: "Authentication",
    path: "/auth",
    redirect: DEFAULT_LOGIN_PATH,
    meta: {
      title: "Authentication",
    },
    children: [
      {
        name: "Login",
        path: "login",
        component: LoginView,
        meta: {
          title: "Login",
        },
      },
      {
        name: "CodeLogin",
        path: "code-login",
        component: () => import("@/layouts/authentication/CodeLoginView.vue"),
        meta: {
          title: "CodeLogin",
        },
      },
      {
        name: "QrCodeLogin",
        path: "qrcode-login",
        component: () => import("@/layouts/authentication/QrCodeLoginView.vue"),
      },
      {
        name: "ForgetPassword",
        path: "forget-password",
        component: () =>
          import("@/layouts/authentication/ForgetPasswordView.vue"),
        meta: {
          title: "ForgetPassword",
        },
      },
      {
        name: "Register",
        path: "register",
        component: () => import("@/layouts/authentication/RegisterView.vue"),
        meta: {
          title: "Register",
        },
      },
    ],
  },
];

export { coreRoutes, fallbackNotFoundRoute };
